﻿using System;
using System.IO;
using UnityEngine;

public static class Texture2DExtensions
{
	public static bool HasAlpha(this Texture2D texture)
	{
		TextureFormat format = texture.format;
		switch (format)
		{
			case TextureFormat.ETC2_RGBA1:
			case TextureFormat.ETC2_RGBA8:
			case TextureFormat.ASTC_4x4:
			case TextureFormat.ASTC_5x5:
			case TextureFormat.ASTC_6x6:
			case TextureFormat.ASTC_8x8:
			case TextureFormat.ASTC_10x10:
			case TextureFormat.ASTC_12x12:
			case TextureFormat.ETC_RGBA8_3DS:
				break;
			default:
				switch (format)
				{
					case TextureFormat.BC6H:
					case TextureFormat.BC7:
#if UNITY_ANDROID //IOS不支持DXT
					case TextureFormat.DXT5Crunched:
#endif
					case TextureFormat.PVRTC_RGBA2:
					case TextureFormat.PVRTC_RGBA4:
						break;
					default:
						switch (format)
						{
#if UNITY_ANDROID //IOS不支持DXT
							case TextureFormat.DXT5:
#endif
							case TextureFormat.RGBA4444:
							case TextureFormat.BGRA32:
							case TextureFormat.RGBAHalf:
							case TextureFormat.RGBAFloat:
								break;
							default:
								switch (format)
								{
									case TextureFormat.Alpha8:
									case TextureFormat.ARGB4444:
									case TextureFormat.RGBA32:
									case TextureFormat.ARGB32:
										break;
									default:
										if (format != TextureFormat.ETC2_RGBA8)
										{
											return false;
										}
										break;
								}
								break;
						}
						break;
				}
				break;
		}
		return true;
	}
}
